﻿using Leeder.Logger;
using NewAndong.Business;
using NewAndong.Model;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace NewAndong.Forms
{
    public partial class FrmMaterialSet : UIPage
    {
        bool isLoad = true;
        AutoSizeFormClass asc = new AutoSizeFormClass();
        public LogOperate LogObj => Log.GetLogger(this.GetType());
        DirectQuoteBLL directQuoteBLL = new DirectQuoteBLL();

        public FrmMaterialSet()
        {
            InitializeComponent();
        }

        private void FrmMaterialSet_Load(object sender, EventArgs e)
        {
            if (!isLoad)
                return;
            isLoad = false;

            Init_Control();
        }

        private void Init_Control()
        {
            List<DirectQuoteModel> directQuoteList = directQuoteBLL.GetModelList();
            var syUseList = directQuoteList.Where(w => w.Type == "SY" && w.IsUse == 1).ToList();
            for (int i = 0; i < syUseList.Count(); i++)
            {
                FrmMaterial2 frmMaterial = new FrmMaterial2(syUseList[i].DirectName, int.Parse(syUseList[i].Where));
                tabControl.AddPage(frmMaterial);
                tabControl.TabPages[i].Text = syUseList[i].DirectName;
            }
        }
    }
}
